import os
import importlib

class GamePlatform:
    def __init__(self):
        self.participants = {}
        self.scores = {}

    def register_participants(self, directory):
        for filename in os.listdir(directory):
            if filename.endswith(".py"):
                name = os.path.splitext(filename)[0]
                try:
                    module = importlib.import_module(name)
                    self.participants[name] = module
                    self.scores[name] = 0
                    print(f"{name}的程序已注册成功！")
                except ImportError:
                    print(f"找不到名为{name}的程序模块！注册失败。")

    # ... 其他方法和逻辑

# 创建游戏平台实例
platform = GamePlatform()

# 注册所有参赛者模块
platform.register_participants("./players")  # "./participants_directory"

# 进行比赛、挑战Boss等操作

# 显示排行榜
platform.show_leaderboard()